package com.cdxy.controller;


import com.cdxy.aop.ForceLogin;
import com.cdxy.biz.process.IAxUserBizProcess;
import com.cdxy.model.dto.base.controller.BaseController;
import com.cdxy.model.dto.base.resp.ApiResponse;
import com.cdxy.model.dto.req.ModifyBindPhoneReq;
import com.cdxy.model.dto.req.ModifyUserInfoReq;
import com.cdxy.model.dto.req.SendMobileCodeReq;
import com.cdxy.util.AxUidUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author autoGenCode
 * @since 2020-03-05
 */
@RestController
@RequestMapping("/axUser")
@Api(tags = "用户")
public class AxUserController extends BaseController {

    @Autowired
    private IAxUserBizProcess axUserBizProcess;

    @Autowired
    private AxUidUtil axUidUtil;

    @PostMapping("/modifyUserInfo")
    @ApiOperation(value = "用户修改个人信息", notes = "")
    @ForceLogin
    public ApiResponse modifyUserInfo(@Validated @RequestBody ModifyUserInfoReq modifyUserInfoReq) {
        modifyUserInfoReq.setAxUid(axUidUtil.getAxUid());
        axUserBizProcess.modifyUserInfo(modifyUserInfoReq);
       return successApiResponse();
    }

    @PostMapping("/modifyBindPhoneSendSms")
    @ApiOperation(value = "改绑）发送手机验证码")
    public ApiResponse modifyBindPhoneSendSms(@Validated @RequestBody SendMobileCodeReq sendMobileCodeReq) {
        axUserBizProcess.modifyBindPhoneSendSms(sendMobileCodeReq);
        return successApiResponse();
    }

    @PostMapping("/modifyBindPhone")
    @ApiOperation(value = "用户改绑手机", notes = "")
    @ForceLogin
    public ApiResponse modifyBindPhone(@Validated @RequestBody ModifyBindPhoneReq modifyBindPhoneReq) {
        modifyBindPhoneReq.setAxUid(axUidUtil.getAxUid());
        axUserBizProcess.modifyBindPhone(modifyBindPhoneReq);
        return successApiResponse();
    }

}
